<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 定义 Person 构造函数
      function Person(name) {
        this.name = name;
      }
      Person.prototype.printName = function () {
        console.log("Name: " + this.name);
      };
      Person.sharedMethod = function () {
        console.log(
          "This is a shared method for all Person and Student objects."
        );
      };

      // 定义 Student 构造函数，继承自 Person
      function Student(name, score) {
        Person.call(this, name);
        this.score = score;
      }
      Student.prototype = Object.create(Person.prototype);
      Student.prototype.constructor = Student;

      // 实例方法：打印分数
      Student.prototype.printScore = function () {
        console.log("Score: " + this.score);
      };
      Student.sharedMethod = Person.sharedMethod;

      // 测试代码
      var person = new Person("Alice");
      person.printName();
      Person.sharedMethod();

      var student = new Student("Bob", 85);
      student.printName();
      student.printScore();
      Student.sharedMethod();
    </script>
  </body>
</html>
